<style>
    table.tecspec>tbody>tr>th,table.tecspec>tbody>tr>td{
        padding: 8px;
        line-height: 1.42857143;
        vertical-align: top;
        border-top: 1px solid #ddd;
    }
    table.tecspec>tbody>tr>th{
        border-right: 1px solid #ddd;
    }
</style>

<?php $this->load->view('templates/backend/header'); ?>

<?php
if(!empty($info)){
    
    ?>
<br/>
<?php echo 'Có '.count($info).' kết quả trả ra:';?>
<?php foreach($info as $key => $values) :?>
<div><?php echo '<h3>'.$this->lang->line("customerID").' : '. $values->customerID.' </h3>';?></div>
<br/>
<div class="table">
        <table class="tecspec" style="width:100%;border-bottom: 1px solid #dddddd">
            <tbody>
            <tr>
              <th style="width:25%"><?php echo 'Số chứng từ';?></th>
              <td width="75%"><?php echo ($values->voucher_id)?$values->voucher_id:' -- Chưa tạo chứng từ --';?></td>
            </tr>    
            <tr>
              <th style="width:25%"><?php echo $this->lang->line('name');?></th>
              <td width="75%"><?php echo $values->name;?></td>
            </tr>
            <?php 
            if($values->owner == $this->session->userdata['user_id']){
            ?>
            <tr>
                <th style="width:25%"><?php echo $this->lang->line('phone');?></th>
                <td width="75%"><?php echo implode(",",json_decode($values->phone));?></td>
            </tr>
            <?php
            }
            ?>
            <tr>
              <th style="width:25%"><?php echo $this->lang->line('customerID');?></th>
              <td width="75%"><?php echo $values->customerID;?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('booking_place_code');?></th>
              <td><?php echo $values->booking_place_code;?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('booking_types');?></th>
              <td><?php echo ($values->booking_types==1)?$this->lang->line('vemoi'):$this->lang->line('xuatdoi');?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('airline');?></th>
              <td><?php echo $values->airline;?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('ship_name_customer');?></th>
              <td><?php echo str_replace('||', '<br/>', $values->booking_customer_name);?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('ship');?></th>
              <td><?php echo implode("<br/>",json_decode($values->booking));?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('net_fare');?></th>
              <td><?php echo $this->bookinglib->my_number_format($values->net_fare,2, ',', ',');?> VNĐ</td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('sale_fare');?></th>
              <td><?php echo $this->bookinglib->my_number_format($values->sale_fare,2, ',', ',');?> VNĐ</td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('payment_method');?></th>
              <td>
                  <?php echo $this->booking_model->getPaymentMethodById($values->payment_method)->payment_name;?>
                  <?php 
                  if($values->owner == $this->session->userdata['user_id']){
                      switch($values->payment_method){
                          case '2':
                              $payment_info     =   $this->ticket_model->find_by(array('booking_id'=>$values->id));
                              $info             =   'Địa chỉ giao vé : '.$payment_info[0]->address;
                              break;
                          case '3':
                              $payment_info     =   $this->bank_model->find_by(array('booking_id'=>$values->id));
                              $bank_info        =   $this->bookbank_model->find_by(array('id'=>$payment_info[0]->bankid));
                              $info             =   $bank_info[0]->bank_name;
                              break;
                      }
                      echo ($info)?" - ".$info:'';
                  }
                  ?>
              </td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('createdTime');?></th>
              <td><?php echo date("d-m-Y H:i:s",$values->createdTime);?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('lastupdated');?></th>
              <td><?php echo date("d-m-Y H:i:s",$values->lastupdated);?></td>
            </tr>
            
            <tr>
              <th><?php echo $this->lang->line('payment_company');?></th>
              <td><?php echo ($values->payment_confirm == 1)?$this->lang->line('paid'):$this->lang->line('unpaid');?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('payment_air');?></th>
              <td><?php echo ($values->payment_air == 1)?$this->lang->line('paid'):$this->lang->line('unpaid');?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('note');?></th>
              <td><?php echo $values->note;?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('booker');?></th>
              <td><?php echo $this->booking_model->getInfoUserByParams(array('key'=>'id', 'value'=>$values->owner))->username;?></td>
            </tr>
            <tr>
              <th><?php echo $this->lang->line('saler');?></th>
              <td><?php echo ($this->booking_model->getInfoSalersById($values->customerID))?$this->booking_model->getInfoSalersById($values->customerID)->username:'';?></td>
            </tr>
          </tbody>
        </table>
</div>
<?php endforeach;?>
    <?php
} else {
    echo 'Không tìm thấy dữ liệu! Vui lòng thử lại sau';
}
die("");